//NormalMappingForwardFX.h
//Created 27/08/13
//Created By Daniel Bowler
//
//Class that represents my NormalMappingForward.fxo effect. A simple effect
//that supports lighting, texturing and normal mapping. 
//
//USE A SOMEWHAT SUBTLE NORMAL MAP PLEASE! If you use an exagerated NM, you
//may find that the backside of a surface (to a light source) will be lit (particually
//with directional lights) because the normal at the point has been modified
//to point in the complete oposite direction - straight in to the light source - thus
//being fully lit. Which is annoying...

#pragma once

#include "AbstractFX.h"

class NormalMappingForwardFX : public AbstractFX
{
	//Ensure that the ShaderManager can access private functions - the constructor/
	//destructor. Thus, the ShaderManager will be the only class allowed to 
	//create/destroy Effects.
	friend ShaderManager;
public:
	//Per vertex structure.
	struct PosNormalTexTangentVertex
	{
		XMFLOAT3 PosL;
		XMFLOAT3 NormalL;
		XMFLOAT2 Tex;
		XMFLOAT3 TangentL;
	};
	//Sets cbuffer data
	void SetCBufferPerObject(CXMMATRIX& world, 
		CXMMATRIX& worldInvTrans, CXMMATRIX& worldViewProj, CXMMATRIX& texTrans, Material& mat);

	//Set Texture Data
	void SetShaderResources(ID3D11ShaderResourceView* diffuseMap = NULL,
		ID3D11ShaderResourceView* normalMap = NULL);

	//Sets lighting data
	void SetCBufferLighting(XMFLOAT3& eye, bool updateLights,
		DirectionalLight* dLights = NULL, unsigned dLightCount = 3,
		PointLight* pLights = NULL, unsigned pLightCount = 100, 
		SpotLight* sLights = NULL, unsigned sLightCount = 100);

private:
	NormalMappingForwardFX(ID3D11Device* device);
	~NormalMappingForwardFX();
	//Disable copy constrcutor and assignment operator
	NormalMappingForwardFX(NormalMappingForwardFX& copy);
	NormalMappingForwardFX& operator=(NormalMappingForwardFX& other);

	//Override the init methods.
	void InitInputLayout(ID3D11Device* device);
	void InitShaderVariablePointers();

private:
	//Variable pointers.
	//
	//Cbuffer Data:
	ID3DX11EffectMatrixVariable* worldVar;
	ID3DX11EffectMatrixVariable* worldInvTransVar;
	ID3DX11EffectMatrixVariable* worldViewProjVar;
	ID3DX11EffectMatrixVariable* texTransformVar;

	//Texture Data:
	ID3DX11EffectShaderResourceVariable* diffuseMapVar; //Texuture mapping.
	ID3DX11EffectShaderResourceVariable* normalMapVar;  //Normal Mapping

	//Lighting data
	ID3DX11EffectVectorVariable* eyePosVar;
	ID3DX11EffectVariable* materialVar;

	ID3DX11EffectVariable* direcLightVar;
	ID3DX11EffectVariable* pointLightVar;
	ID3DX11EffectVariable* spotLightVar;
};